﻿using RPAVIEW.util;
using RPAVIEW.views.controlLibrary;
using SUNRPA.CONTROLS.IMPL.util;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;

namespace RPAVIEW.views.EditPage.flows.SaveOrSaveAsExcelN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            this.saveObject.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.saveAsPath.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.saveWay.GetBindingExpression(System.Windows.Controls.ComboBox.SelectedIndexProperty).UpdateSource();
            this.coverIfExist.GetBindingExpression(System.Windows.Controls.CheckBox.IsCheckedProperty).UpdateSource();
            this.closeAfterSave.GetBindingExpression(System.Windows.Controls.CheckBox.IsCheckedProperty).UpdateSource();
        }

        private void SelectSaveAsPath(object sender, RoutedEventArgs e) {
            SaveFileDialog saveDialog =  FileUtil.OpenSaveFileDialog(".xls;.xlsx|*.xls;*.xlsx");
            saveDialog.FileName = "WorkBook.xlsx";
            saveDialog.ShowDialog();
            this.saveAsPath.Text = saveDialog.FileName;
        }

        private void SaveWayChanged(object sender, SelectionChangedEventArgs e) {
            int saveWay = this.saveWay.SelectedIndex;
            if(saveWay == 0) {
                ElementUtil.HideRow(this.pathRow);
                ElementUtil.HideRow(this.coverRow);
            } else { 
                ElementUtil.ShowRow(this.pathRow);
                ElementUtil.ShowRow(this.coverRow);
            }
        }
    }
}
